let CryptoJS = require("crypto-js");

// 加密
const key = 'DbaCsNokAll#kJQ4RSWx*wz5L8DHD#kN'
const keyHex = CryptoJS.enc.Utf8.parse(key)
let desPassword = CryptoJS.DES.encrypt('fyx12345678...', keyHex, {
    mode: CryptoJS.mode.ECB,
    padding: CryptoJS.pad.Pkcs7
}).toString()
console.log('加密desPassword111', desPassword)
desPassword = decodeURIComponent(desPassword)
console.log('加密desPassword222', desPassword) // 服务端通常的做法是直接存储加密后的字符串，而不是解密后存储

// 解密
let flag = false
if(flag) {
    let decrypted = CryptoJS.DES.decrypt(desPassword, keyHex, {
        mode: CryptoJS.mode.ECB,
        padding: CryptoJS.pad.Pkcs7
    })
    let decryptedString = CryptoJS.enc.Utf8.stringify(decrypted)
    console.log('解密decrypted', decryptedString)
}
